xen.git
14 years agoxen.lowlevel.xl: Return None on empty domain name
Marek Marczykowski [Mon, 27 Jun 2011 16:34:01 +0000 (17:34 +0100)]
xen.lowlevel.xl: Return None on empty domain name

Previously PyString_FromString(NULL) was called, which caused assertion
failure.

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: Remove frontend and backend devices from xenstore after destroy
Marek Marczykowski [Mon, 27 Jun 2011 16:28:52 +0000 (17:28 +0100)]
libxl: Remove frontend and backend devices from xenstore after destroy

Cleanup frontend and backend devices from xenstore for all dev types - not only
disks. Because backend cleanup moved to libxl__device_destroy,
libxl__devices_destroy is somehow simpler.

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: Accept disk name in libxl_devid_to_device_disk
Marek Marczykowski [Mon, 27 Jun 2011 16:27:08 +0000 (17:27 +0100)]
libxl: Accept disk name in libxl_devid_to_device_disk

Accept disk name in xl block-detach.

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: Allocate memory for strings in libxl_device_disk
Marek Marczykowski [Mon, 27 Jun 2011 16:24:50 +0000 (17:24 +0100)]
libxl: Allocate memory for strings in libxl_device_disk

Memory for strings in libxl_device_disk must be allocated from outside of
libxl__gc to not be freed at the end of function (by libxl__free_all).

Fixes xl block-detach

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoxl: Use macros for param parsing in network-attach
Marek Marczykowski [Mon, 27 Jun 2011 16:20:55 +0000 (17:20 +0100)]
xl: Use macros for param parsing in network-attach

'script=' length was wrong... Replaced calls to strncmp("param", *argv,
explicit sizeof("param")) with macro and helper function to extract parameter
value. Also introduce replace_string function to simplify code.

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: Introduce XEN_RUN_DIR path.
Anthony PERARD [Mon, 27 Jun 2011 16:07:35 +0000 (17:07 +0100)]
tools: Introduce XEN_RUN_DIR path.

This patch also add libxl_run_dir_path() function in libxl.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoremus: handle exceptions while installing/unstalling net buffer
Signed-off-by: Shriram Rajagopalan [Mon, 27 Jun 2011 14:18:38 +0000 (15:18 +0100)]
remus: handle exceptions while installing/unstalling net buffer

Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: fix build after recent xenpaging changes
Tim Deegan [Mon, 27 Jun 2011 13:48:57 +0000 (14:48 +0100)]
tools: fix build after recent xenpaging changes

xenpaging now uses pthreads, so must link appropriately.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoMerge
Ian Jackson [Thu, 23 Jun 2011 17:34:55 +0000 (18:34 +0100)]
Merge

14 years agox86: show page walk also for early page faults
Jan Beulich [Thu, 23 Jun 2011 10:35:55 +0000 (11:35 +0100)]
x86: show page walk also for early page faults

At once, move the common (between 32- and 64-bit) definition of
machine_to_phys_mapping_valid to a common location.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86/DMI: use proper structures instead of byte offsets
Jan Beulich [Thu, 23 Jun 2011 10:34:40 +0000 (11:34 +0100)]
x86/DMI: use proper structures instead of byte offsets

Besides being (in my eyes) desirable cleanup, this at once represents
another prerequisite for native EFI booting support.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86: allow Dom0 image to be compressed ELF
Jan Beulich [Thu, 23 Jun 2011 10:33:57 +0000 (11:33 +0100)]
x86: allow Dom0 image to be compressed ELF

Rather than being able to decompress only the payloads of bzImage
containers, extend the logic to also decompress simple compressed ELF
images. At once, allow uncompressed bzImage payloads.

This is a prerequisite for native EFI booting support (where, in the
absence of a capable secondary boot loader, the image will always be
in compressed form).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agoreplace d->nr_pirqs sized arrays with radix tree
Jan Beulich [Thu, 23 Jun 2011 10:32:43 +0000 (11:32 +0100)]
replace d->nr_pirqs sized arrays with radix tree

With this it is questionable whether retaining struct domain's
nr_pirqs is actually necessary - the value now only serves for bounds
checking, and this boundary could easily be nr_irqs.

Note that ia64, the build of which is broken currently anyway, is only
being partially fixed up.

v2: adjustments for split setup/teardown of translation data

v3: re-sync with radix tree implementation changes

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agoSimplify preempt.h dependencies by moving in_atomic() to preempt.c
Keir Fraser [Thu, 23 Jun 2011 10:27:38 +0000 (11:27 +0100)]
Simplify preempt.h dependencies by moving in_atomic() to preempt.c

..clean up the ensuing fallout.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years ago[VTD] print out debug message in vt-d fault handler only when iommu=debug is set
Allen Kay [Thu, 23 Jun 2011 10:11:24 +0000 (11:11 +0100)]
[VTD] print out debug message in vt-d fault handler only when iommu=debug is set

Print out debug messages in vtd_page_fault() handler only when
iommu=debug is set xen boot parameter.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
14 years agolibxl: remove and hgignore testenum.c
Ian Jackson [Wed, 22 Jun 2011 13:43:53 +0000 (14:43 +0100)]
libxl: remove and hgignore testenum.c

This is an output file from the test idl generator and should not have
been committed.

Reported-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoQEMU_TAG update
Ian Jackson [Tue, 21 Jun 2011 17:28:53 +0000 (18:28 +0100)]
QEMU_TAG update

14 years agolibxl: autogenerate to_string and from_string functions for Enumerations.
Ian Campbell [Tue, 21 Jun 2011 17:26:39 +0000 (18:26 +0100)]
libxl: autogenerate to_string and from_string functions for Enumerations.

The generated strings are the lower case enum value names, with underscores.
Accepted string for parsing are the same but are case insensitive.

We provide a table of strings->value for each Enumeration as well as a
convenience function to perform a lookup.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoxl: improve compatibility with xm
Carsten Schiers [Tue, 21 Jun 2011 17:24:34 +0000 (18:24 +0100)]
xl: improve compatibility with xm

/etc/init.d/xendomains relies on simple pattern matching from sructures
being printed by "xl list -l" command. so update xl implementation to
match.

Signed-off-by: Carsten Schiers <carsten@schiers.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools/ocaml: ask compiler for correct library
Mike McClurg [Tue, 21 Jun 2011 17:01:51 +0000 (18:01 +0100)]
tools/ocaml: ask compiler for correct library

OCaml libraries will live in /usr/local/ if the user compiles OCaml
from source. This patch asks the OCaml compiler where we should look
for libraries.

NB: it may be that we should do the same thing for the NetBSD case,
but I don't have a BSD box to test this out.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: add all pci devices to xenstore at once (during VM create)
Marek Marczykowski [Tue, 21 Jun 2011 16:50:47 +0000 (17:50 +0100)]
libxl: add all pci devices to xenstore at once (during VM create)

When adding pci devices one by one, pciback notice only the first one. For
every next, "state" is left as is (usualy "4" in that time), so backend will
not rescan xenstore. So when VM is starting all devices should be added at once
and then backend can initialize it.

This applies only to pci, because only pci backend have one xenstore dir for
multiple devices.

Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agomake xendomains service save/migrate vms under /etc/xen/auto only
Zhigang Wang [Tue, 21 Jun 2011 16:48:00 +0000 (17:48 +0100)]
make xendomains service save/migrate vms under /etc/xen/auto only

Currently, xendomains service will save or migrate all the running domains in
the host on stop.

Change XENDOMAINS_AUTO_ONLY=true. Then on service stop, it will only
save or migrate all VMs under XENDOMAINS_AUTO (/etc/xen/auto), but always
shutdown all the running VMs.

It's a way to cleanly shutdown all the running VMs on system reboot. If you
want to save/migrate a VM, create a link to /etc/xen/auto.

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: always set list out parameter of libxl_device_pci_list_assigned
Stefano Stabellini [Tue, 21 Jun 2011 16:35:57 +0000 (17:35 +0100)]
libxl: always set list out parameter of libxl_device_pci_list_assigned

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoxenpaging: remove private mem_event.h
Olaf Hering [Fri, 10 Jun 2011 08:47:29 +0000 (10:47 +0200)]
xenpaging: remove private mem_event.h

tools/xenpaging/mem_event.h is only included in xenpaging.h.
Add the contents into that file and remove mem_event.h.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: implement stopping of pager by sending SIGTERM/SIGINT
Olaf Hering [Fri, 10 Jun 2011 08:47:28 +0000 (10:47 +0200)]
xenpaging: implement stopping of pager by sending SIGTERM/SIGINT

Write all paged-out pages back into the guest if the pager is
interrupted by ctrl-c or if it receives SIGTERM.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: add watch thread to catch guest shutdown
Olaf Hering [Fri, 10 Jun 2011 08:47:27 +0000 (10:47 +0200)]
xenpaging: add watch thread to catch guest shutdown

If xenpaging is started manually then no event is sent to xenpaging when
the guest is shutdown or rebooted.  Add a watch on the @releaseDomain
node to leave the loop and gracefully shutdown the pager.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: add helper function for unlinking pagefile
Olaf Hering [Fri, 10 Jun 2011 08:47:25 +0000 (10:47 +0200)]
xenpaging: add helper function for unlinking pagefile

Unlink pagefile in the signal handler and also in the exit path.
This does not leave a stale pagefile if an error occoured.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: pass integer to xenpaging_populate_page
Olaf Hering [Fri, 10 Jun 2011 08:47:24 +0000 (10:47 +0200)]
xenpaging: pass integer to xenpaging_populate_page

Pass gfn as integer to xenpaging_populate_page(). xc_map_foreign_pages()
takes a pointer to a list of gfns, but its a const pointer. So writing
the value back to the caller is not needed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: start paging in the middle of gfn range
Olaf Hering [Fri, 10 Jun 2011 08:47:23 +0000 (10:47 +0200)]
xenpaging: start paging in the middle of gfn range

Set the starting gfn to somewhere in the middle of the gfn range to
avoid paging during BIOS startup. This can speedup booting of a guest.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: move num_pages into xenpaging struct
Olaf Hering [Fri, 10 Jun 2011 08:47:22 +0000 (10:47 +0200)]
xenpaging: move num_pages into xenpaging struct

Move num_pages into struct xenpaging.
num_pages will be used by the policy in a subsequent patch.

Also remove a memset, the victims array is allocated with calloc.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: remove local domain_id variable
Olaf Hering [Fri, 10 Jun 2011 08:47:20 +0000 (10:47 +0200)]
xenpaging: remove local domain_id variable

Remove the local domain_id variable, it is already fetched from
paging->mem_event in other places.
Update the sprintf format string to use unsigned argument.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: catch xc_mem_paging_resume errors
Olaf Hering [Fri, 10 Jun 2011 08:47:19 +0000 (10:47 +0200)]
xenpaging: catch xc_mem_paging_resume errors

In the unlikely event that xc_mem_paging_resume() fails, do not overwrite the
error with the return value from xc_evtchn_notify()

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: remove return values from functions that can not fail
Olaf Hering [Fri, 10 Jun 2011 08:47:18 +0000 (10:47 +0200)]
xenpaging: remove return values from functions that can not fail

get_request() and put_response() can not fail, remove return value
and update calling functions.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: remove srand call
Olaf Hering [Fri, 10 Jun 2011 08:47:16 +0000 (10:47 +0200)]
xenpaging: remove srand call

The policy uses now a linear algorithm instead of a random one.
Remove the call to srand().

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: do not bounce p2mt back to the hypervisor
Olaf Hering [Wed, 22 Jun 2011 13:47:13 +0000 (14:47 +0100)]
xenpaging: do not bounce p2mt back to the hypervisor

do not bounce p2mt back to the hypervisor because p2m_mem_paging_populate()
and p2m_mem_paging_resume() dont make use of p2mt.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: correct dropping of pages to avoid full ring buffer
Olaf Hering [Fri, 10 Jun 2011 08:47:14 +0000 (10:47 +0200)]
xenpaging: correct dropping of pages to avoid full ring buffer

Doing a one-way channel from Xen to xenpaging is not possible with the
current ring buffer implementation. xenpaging uses the mem_event ring
buffer, which expects request/response pairs to make progress. The
previous patch, which tried to establish a one-way communication from
Xen to xenpaging, stalled the guest once the buffer was filled up with
requests. Correct page-dropping by taking the slow path and let
p2m_mem_paging_resume() consume the response from xenpaging. This makes
room for yet another request/response pair and avoids hanging guests.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, remove xc files
Olaf Hering [Fri, 10 Jun 2011 08:47:12 +0000 (10:47 +0200)]
xenpaging: drop xc.c, remove xc files

Finally remove xc.c/xc.h and its references since both are empty now.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, move xc_wait_for_event_or_timeout
Olaf Hering [Fri, 10 Jun 2011 08:47:11 +0000 (10:47 +0200)]
xenpaging: drop xc.c, move xc_wait_for_event_or_timeout

Move xc_wait_for_event_or_timeout() into xenpaging and massage it a bit for
further changes in subsequent patches.
Include poll.h instead of sys/poll.h.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache
Olaf Hering [Fri, 10 Jun 2011 08:47:10 +0000 (10:47 +0200)]
xenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache

Move xc_mem_paging_flush_ioemu_cache() into xenpaging and massage it a bit to
use the required members from xenpaging_t.
Also update type of rc to match xs_write() return value.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, remove xc_wait_for_event
Olaf Hering [Fri, 10 Jun 2011 08:47:08 +0000 (10:47 +0200)]
xenpaging: drop xc.c, remove xc_wait_for_event

xc_wait_for_event is not used in xenpaging.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, remove xc_platform_info_t
Olaf Hering [Fri, 10 Jun 2011 08:47:07 +0000 (10:47 +0200)]
xenpaging: drop xc.c, remove xc_platform_info_t

xc_platform_info_t is not used in xenpaging.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: drop xc.c, remove ASSERT
Olaf Hering [Fri, 10 Jun 2011 08:47:06 +0000 (10:47 +0200)]
xenpaging: drop xc.c, remove ASSERT

The ASSERT is not needed, victim is never NULL.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: add xs_handle to struct xenpaging
Olaf Hering [Wed, 22 Jun 2011 13:47:09 +0000 (14:47 +0100)]
xenpaging: add xs_handle to struct xenpaging

A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache()
function and will be used by a subsequent patch.
Add it to struct xenpaging.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
14 years agotools: merge several bitop functions into xc_bitops.h
Olaf Hering [Fri, 10 Jun 2011 08:47:03 +0000 (10:47 +0200)]
tools: merge several bitop functions into xc_bitops.h

Bitmaps are used in save/restore, xenpaging and blktap2.  Merge the code into a
private xc_bitops.h file. All users are single threaded, so locking is not an
issue. The array of bits is handled as volatile because the x86 save/restore
code passes the bitmap to the hypervisor which in turn modifies the bitmap.

blktap2 uses a private bitmap. There was a possible overflow in the
bitmap_size() function, the remainder was not considered.

ia64 save/restore uses a bitmap to send the number of vcpus to the host.

x86 save/restore uses a bitmap to track dirty pages. This bitmap is shared with
the hypervisor. An unused function count_bits() was removed and a new
bitmap_size() function is now used.

xenpaging uses 3 private bitmaps to track the gfns which are in paged-out
state.  It had a copy of some Linux bitops.h, which is now obsolete. Also the
BITS_PER_LONG macro was hardcoded to 64 which made it impossible to run 32bit
tools on a 64bit host. Wether this works at all has to be tested, yet.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenpaging: remove unused spinlock in pager
Olaf Hering [Fri, 10 Jun 2011 08:47:02 +0000 (10:47 +0200)]
xenpaging: remove unused spinlock in pager

The spinlock code in the pager is a no-op because xenpaging is a single
threaded application. There is no locking when put_response() places a
response into the ringbuffer.
The only locking is inside the hypervisor, where mem_event_put_request() and
mem_event_get_response() lock the ringbuffer to protect multiple vcpus from
each other.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agotools/blktap2: tapdisk2 executable usage message documents -D option
Philipp Hahn [Tue, 21 Jun 2011 15:51:43 +0000 (16:51 +0100)]
tools/blktap2: tapdisk2 executable usage message documents -D option

Signed-off-by: Philipp Hahn <hahn@univention.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoxenctx: add option -C to dump context for all vcpus
Olaf Hering [Fri, 17 Jun 2011 12:22:56 +0000 (14:22 +0200)]
xenctx: add option -C to dump context for all vcpus

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenctx: move xc_* access out of dump_ctx
Olaf Hering [Fri, 17 Jun 2011 12:11:52 +0000 (14:11 +0200)]
xenctx: move xc_* access out of dump_ctx

move xc_* access out of dump_ctx.
Update code paths to return an error instead of calling exit().
On error unpause the guest if it was paused by xenctx.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenctx: move all globals into struct xenctx
Olaf Hering [Fri, 17 Jun 2011 12:10:18 +0000 (14:10 +0200)]
xenctx: move all globals into struct xenctx

Move all globals used for options and libxc data into a new struct xenctx.
This is used in subsequent changes.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agoxenctx: recognize also -S option for --stack-trace
Olaf Hering [Fri, 17 Jun 2011 12:09:32 +0000 (14:09 +0200)]
xenctx: recognize also -S option for --stack-trace

Update help text.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agotools: xen-ringwatch: spot, and work around, broken frontend/backend ring I/O
Daniel Stodden [Tue, 21 Jun 2011 14:38:52 +0000 (15:38 +0100)]
tools: xen-ringwatch: spot, and work around, broken frontend/backend ring I/O

Adds tool support to debug backends which expose I/O ring state in
sysfs. Currently supports /sys/devices/xen-backend/vbd-*-*/io_ring
nodes for block I/O, where implemented.

Primary function is to observe ring state make progress over a period
of time, then report stuck message queue halves where pending
consumer/event are not moving.

Adding --kick will re-issue event notifications to frontends, and/or
kick backends out of wait state.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: remove O_CLOEXEC in xl_cmdimpl.c
Yongjie Ren [Tue, 21 Jun 2011 14:31:34 +0000 (15:31 +0100)]
libxl: remove O_CLOEXEC in xl_cmdimpl.c

Some old linux kernels such as 2.6.18 don't define O_CLOEXEC, so
remove O_CLOEXEC in xl_cmdimpl.c and replace with fcntl.

Signed-off-by: Yongjie Ren <yongjie.ren@intel.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agox86/mm/shadow: adjust early-unshadow heuristic for PAE guests.
Tim Deegan [Mon, 20 Jun 2011 12:16:14 +0000 (13:16 +0100)]
x86/mm/shadow: adjust early-unshadow heuristic for PAE guests.

PAE guests have 8-byte PTEs but tend to clear memory with 4-byte writes.
This means that when zeroing a former pagetable every second 4-byte
write is unaligned and so the consecutive-zeroes --> unshadow
heuristic never kicks in.  Adjust the heuristic not to reset when
a write is >= 4 bytes and writing zero but not PTE-aligned.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoxen-detect: Fix cpuid asm for 32-bit PIC compilation.
Keir Fraser [Fri, 17 Jun 2011 07:08:13 +0000 (08:08 +0100)]
xen-detect: Fix cpuid asm for 32-bit PIC compilation.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agotasklets: Switch a few tasklets to run in softirq context.
Keir Fraser [Thu, 16 Jun 2011 15:57:22 +0000 (16:57 +0100)]
tasklets: Switch a few tasklets to run in softirq context.

There are a couple of others which may also be safe. I've converted
only the most obvious one.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agotasklets: Allow tasklets to be created that run in softirq context.
Keir Fraser [Thu, 16 Jun 2011 15:56:31 +0000 (16:56 +0100)]
tasklets: Allow tasklets to be created that run in softirq context.

Where this is safe, it can reduce latency and cpu overhead compared
with scheduling the idle vcpu to perform the same tasklet work.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agopv-on-hvm: hvm_domain_use_pirq return positive no matter if the evtchn is bound
Stefano Stabellini [Thu, 16 Jun 2011 15:17:35 +0000 (16:17 +0100)]
pv-on-hvm: hvm_domain_use_pirq return positive no matter if the evtchn is bound

This patch fixes PV on HVM interrupt remapping with recent Linux
kernels and upstream qemu.  hvm_domain_use_pirq should return positive
even if the evtchn is not currently bound. If it doesn't assert_irq
ends up injecting legacy interrupts even after the guest disabled the
irq.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
14 years agoProtect xen/stdarg.h for multiple inclusion.
Keir Fraser [Thu, 16 Jun 2011 15:14:51 +0000 (16:14 +0100)]
Protect xen/stdarg.h for multiple inclusion.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agoUse same data array for INTEL and AMD cpufreq handling
Juergen Gross [Thu, 16 Jun 2011 15:12:20 +0000 (16:12 +0100)]
Use same data array for INTEL and AMD cpufreq handling

The AMD and INTEL specific parts of cpufreq handling used different
per-cpu data structures with nearly identical semantics.  Fold the two
structures into one by adding a generic architecture data item.

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
14 years agoKEXEC: prevent panic on the kexec path when talking to the DMAR
Andrew Cooper [Thu, 16 Jun 2011 15:11:13 +0000 (16:11 +0100)]
KEXEC: prevent panic on the kexec path when talking to the DMAR
hardware

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 years agox86_emulate: Fix decode of FUCOMIP %stN.
Keir Fraser [Wed, 15 Jun 2011 19:33:58 +0000 (20:33 +0100)]
x86_emulate: Fix decode of FUCOMIP %stN.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86: sync thermal monitor LVT handling with Linux
Jan Beulich [Wed, 15 Jun 2011 19:25:13 +0000 (20:25 +0100)]
x86: sync thermal monitor LVT handling with Linux

As of 2.6.33, Linux checks that the thermal monitor LVT isn't set to
SMI delivery mode on just the value read on the boot CPU. As of 2.6.39
it additionally avoids writing back the saved value when its delivery
mode is FIXED (as this can cause APIC errors).

Changes done here that aren't in Linux are
- write back the boot CPU value also if delivery mode is FIXED, but
  there is also a valid vector
- print the messages when bailing out only once (on the boot CPU)
- when doing the final (enabling) write to the LVT, don't re-read the
  old value from the APIC, as we have it in a local variable already

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86/apic: check maxlvt before accessing certain LVT fields
Jan Beulich [Wed, 15 Jun 2011 19:24:41 +0000 (20:24 +0100)]
x86/apic: check maxlvt before accessing certain LVT fields

This follows Linux, including in not checking maxlvt for certain
accesses to APIC_LVTERR.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86-64: fix incorrect assertion in __maddr_to_virt()
Jan Beulich [Wed, 15 Jun 2011 19:24:09 +0000 (20:24 +0100)]
x86-64: fix incorrect assertion in __maddr_to_virt()

When memory map sparseness reduction is in use, machine address ranges
can't validly be compared directly against the total size of the
direct mapping range.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agoKEXEC: correctly revert x2apic state when kexecing
Andrew Cooper [Wed, 15 Jun 2011 15:16:41 +0000 (16:16 +0100)]
KEXEC: correctly revert x2apic state when kexecing

Introduce the boolean variable 'kexecing' which indicates to functions
whether we are on the kexec path or not.  This is used by
disable_local_APIC() to try and revert the APIC mode back to how it
was found on boot.

We also need some fudging of the x2apic_enabled variable.  It is used
in multiple places over the codebase to mean multiple things,
including:
    What did the user specifify on the command line?
    Did the BIOS boot me in x2apic mode?
    Is the BSP Local APIC in x2apic mode?
    What mode is my Local APIC in?

Therefore, set it up to prevent a protection fault when disabling the
IOAPICs.  (In this case, it is used in the "What mode is my Local APIC
in?" case, so the processor doesnt suffer a protection fault because
of trying to use x2apic MSRs when it should be using xapic MMIO)

Finally, make sure that interrupts are disabled when jumping into the
purgatory code.  It would be bad to service interrupts in the Xen
context when the next kernel is booting.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 years agoIOMMU: add crash_shutdown iommu_op
Andrew Cooper [Wed, 15 Jun 2011 15:10:11 +0000 (16:10 +0100)]
IOMMU: add crash_shutdown iommu_op

The kdump kernel has problems booting with interrupt/dma
remapping enabled, so we need a new iommu_ops called
crash_shutdown which is basically suspend but doesn't
need to bother saving state.

Make sure that crash_shutdown is called on the kexec
path.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 years agoIOMMU VTD BUG: disable Extended Interrupt Mode when disabling Interupt
Andrew Cooper [Wed, 15 Jun 2011 15:07:45 +0000 (16:07 +0100)]
IOMMU VTD BUG: disable Extended Interrupt Mode when disabling Interupt
Remapping

Experimental evidence shows that Extended Interrupt Mode remains in
effect even after Interrupt Remapping is disabled in each DMAR Global
Command Register.  A consiquence of this is that when we switch from
x2apic mode back to xapic mode, and disable interrupt remapping for
the kdump kernel, interrupts passing through the IO APICs are in
x2apic format as opposed xapic.  This causes a triple fault in the
kexec kernel.

As EIM is explicitly set up each time Interrup Remapping is enabled,
it is safe for us to clobber this when taring down.

Also, change the header definition of IRTA_REG_EIME_SHIFT.  It caused
verbose and error-prone code, and was only used in 1 place before.  We
now have IRTA_EIME which is the specific bit in the register.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 years agoEnable RDWRGSFS feature support for HVM guests
Yang, Wei [Wed, 15 Jun 2011 15:06:48 +0000 (16:06 +0100)]
Enable RDWRGSFS feature support for HVM guests

Write/read FS/GS base instructions enable user level code to
read/write FS & GS segment base registers for thread local storage.

Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
14 years agox86/hvm: Crash domain rather than guest on unexpected PIO IO state
George Dunlap [Wed, 15 Jun 2011 15:05:14 +0000 (16:05 +0100)]
x86/hvm: Crash domain rather than guest on unexpected PIO IO state

Under certain conditions, if an IO gets into an unexpected state,
hvmemul_do_io can return X86EMUL_UNHANDLEABLE.  Unfortunately,
handle_pio() does not expect this state, and calls BUG() if it sees
it, crashing the host.

Other HVM io-related code crashes the guest in this case.  This patch
makes handle_pio() do the same.

The crash was seen when executing crash_guest in dom0 to forcibly
crash the guest.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
14 years agoNested VMX: n2 MSR handling and capability exposure
Tim Deegan [Wed, 15 Jun 2011 12:33:58 +0000 (13:33 +0100)]
Nested VMX: n2 MSR handling and capability exposure

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Add VMXE bits in virtual CR4
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Add VMXE bits in virtual CR4

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Lazy FPU for n2 guest
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Lazy FPU for n2 guest

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: VM exit handler of n2-guest
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: VM exit handler of n2-guest

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: interrupt/exception handling for n2 guest
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: interrupt/exception handling for n2 guest

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Switch shadow/virtual VMCS between n1/n2 guests.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Switch shadow/virtual VMCS between n1/n2 guests.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Extend VMCS control fields for n2 guest
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Extend VMCS control fields for n2 guest

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of VMRESUME/VMLAUNCH
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of VMRESUME/VMLAUNCH

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Add APIs to switch n1/n2 VMCS.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Add APIs to switch n1/n2 VMCS.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNexted VMX: Emulation of guest VMREAD
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nexted VMX: Emulation of guest VMREAD

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of guest VMWRITE
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of guest VMWRITE

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of guest VMCLEAR
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of guest VMCLEAR

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of guest VMPTRST
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of guest VMPTRST

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of guest vmptrld
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of guest vmptrld

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Define structure and access APIs for virtual VMCS.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Define structure and access APIs for virtual VMCS.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Emulation of guest VMXON/OFF instruction.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Emulation of guest VMXON/OFF instruction.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Add APIs for nestedhvm_ops.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Add APIs for nestedhvm_ops.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoNested VMX: Add data structure for nestedvmx
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
Nested VMX: Add data structure for nestedvmx

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agox86/hvm: Move IDT_VECTORING processing code out of intr_assist.
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
x86/hvm: Move IDT_VECTORING processing code out of intr_assist.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agox86/hvm: extend nhvm_vmcx_guest_intercepts_trap to include errcode
Eddie Dong [Thu, 9 Jun 2011 08:24:09 +0000 (16:24 +0800)]
x86/hvm: extend nhvm_vmcx_guest_intercepts_trap to include errcode
to assist decision of TRAP_page_fault in VMX.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
Committed-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agox86/mm/p2m: Move check for non-translated guests in one layer
Tim Deegan [Wed, 15 Jun 2011 11:02:07 +0000 (12:02 +0100)]
x86/mm/p2m: Move check for non-translated guests in one layer
so that direct callers of gfn_to_mfn_type_p2m() can operate safely
on PV domains.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agox86: Pass through ERMS CPUID feature for HVM and PV guests
Yang, Wei [Tue, 14 Jun 2011 12:13:18 +0000 (13:13 +0100)]
x86: Pass through ERMS CPUID feature for HVM and PV guests

This patch exposes ERMS feature to HVM and PV guests.

The REP MOVSB/STOSB instruction can enhance fast strings attempts to
move as much of the data with larger size load/stores as possible.

Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
14 years agoIOMMU VTD BUG: disable Extended Interrupt Mode when disabling Interrupt Remapping
Andrew Cooper [Tue, 14 Jun 2011 12:04:09 +0000 (13:04 +0100)]
IOMMU VTD BUG: disable Extended Interrupt Mode when disabling Interrupt Remapping

Experimental evidence shows that Extended Interrupt Mode remains in
effect even after Interrupt Remapping is disabled in each DMAR Global
Command Register.  A consiquence of this is that when we switch from
x2apic mode back to xapic mode, and disable interrupt remapping for
the kdump kernel, interrupts passing through the IO APICs are in
x2apic format as opposed xapic.  This causes a triple fault in the
kexec kernel.

As EIM is explicitly set up each time Interrup Remapping is enabled,
it is safe for us to clobber this when taring down.

Also, change the header definition of IRTA_REG_EIME_SHIFT.  It caused
verbose and error-prone code, and was only used in 1 place before.  We
now have IRTA_EIME which is the specific bit in the register.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 years agox86/apic: record local APIC state on boot
Andrew Cooper [Tue, 14 Jun 2011 12:02:00 +0000 (13:02 +0100)]
x86/apic: record local APIC state on boot

Xen does not store the boot local APIC state which leads to problems
when shutting down for a kexec jump.  This patch records the boot
state so we can return to the boot state when kexecing.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
Acked-by: Jan Beulich <jbeulich@novell.com>
14 years agox86/kexec: nmi_shootdown_cpus() should leave irqs disabled
Keir Fraser [Tue, 14 Jun 2011 11:49:41 +0000 (12:49 +0100)]
x86/kexec: nmi_shootdown_cpus() should leave irqs disabled

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/apic: fix potential Protection Fault during shutdown
Andrew Cooper [Tue, 14 Jun 2011 11:47:45 +0000 (12:47 +0100)]
x86/apic: fix potential Protection Fault during shutdown

This is a rare case, but if the BIOS is set to uniprocessor, and Xen
is booted with 'lapic x2apic', Xen will switch into x2apic mode, which
will cause a protection fault when disabling the local APIC.  This
leads to a general protection fault as this code is also in the fault
handler.

When x2apic mode is enabled, the only tranlsation which does
not result in a protection fault is to clear both the EN and EXTD
bits, which is safe to do in all cases, even if you are in xapic
mode rather than x2apic mode.

The linux code from which this is derrived is protected by an
if ( ! x2apic_mode ...) clause which is how they get away with it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@novell.com>
14 years agox86/amd: Eliminate cache flushing when entering C3 on select AMD processors
Mark Langsdorf [Tue, 14 Jun 2011 11:46:29 +0000 (12:46 +0100)]
x86/amd: Eliminate cache flushing when entering C3 on select AMD processors

AMD Fam15h processors have a shared cache. It does not need=20
to be be flushed when entering C3 and doing so causes reduces
performance. Modify acpi_processor_power_init_bm_check to
prevent these processors from flushing when entering C3.

Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>
14 years agox86/hvm: Make DRNG feature visible in CPUID
Yang, Wei [Tue, 14 Jun 2011 11:44:48 +0000 (12:44 +0100)]
x86/hvm: Make DRNG feature visible in CPUID

This patch exposes DRNG feature to HVM guests.

The RDRAND instruction can provide software with sequences of
random numbers generated from white noise.

Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
14 years agox86_32: Fix build: Define machine_to_phys_mapping_valid
Keir Fraser [Fri, 10 Jun 2011 12:51:39 +0000 (13:51 +0100)]
x86_32: Fix build: Define machine_to_phys_mapping_valid

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/vmx: Small fixes to MSR_IA32_VMX_PROCBASED_CTLS feature probing.
Keir Fraser [Fri, 10 Jun 2011 07:32:47 +0000 (08:32 +0100)]
x86/vmx: Small fixes to MSR_IA32_VMX_PROCBASED_CTLS feature probing.

Should check for VIRTUAL_INTR_PENDING as we unconditionally make use
of it. Also check for CR8 exiting unconditionally on x86/64, as this
is of use to nestedvmx, and every 64-bit cpu should support it.

Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Keir Fraser <keir@xen.org>
14 years agoxenpaging: update machine_to_phys_mapping[] during page deallocation
Keir Fraser [Fri, 10 Jun 2011 07:19:07 +0000 (08:19 +0100)]
xenpaging: update machine_to_phys_mapping[] during page deallocation

The machine_to_phys_mapping[] array needs updating during page
deallocation.  If that page is allocated again, a call to
get_gpfn_from_mfn() will still return an old gfn from another guest.
This will cause trouble because this gfn number has no or different
meaning in the context of the current guest.

This happens when the entire guest ram is paged-out before
xen_vga_populate_vram() runs.  Then XENMEM_populate_physmap is called
with gfn 0xff000.  A new page is allocated with alloc_domheap_pages.
This new page does not have a gfn yet.  However, in
guest_physmap_add_entry() the passed mfn maps still to an old gfn
(perhaps from another old guest).  This old gfn is in paged-out state
in this guests context and has no mfn anymore.  As a result, the
ASSERT() triggers because p2m_is_ram() is true for p2m_ram_paging*
types.  If the machine_to_phys_mapping[] array is updated properly,
both loops in guest_physmap_add_entry() turn into no-ops for the new
page and the mfn/gfn mapping will be done at the end of the function.

If XENMEM_add_to_physmap is used with XENMAPSPACE_gmfn,
get_gpfn_from_mfn() will return an appearently valid gfn.  As a
result, guest_physmap_remove_page() is called.  The ASSERT in
p2m_remove_page triggers because the passed mfn does not match the old
mfn for the passed gfn.

Signed-off-by: Olaf Hering <olaf@aepfle.de>